<template>
  <div class="card-box">
    <div class="home-title">问题交办单</div>
    <div class="content">
      <div
        class="item"
        :class="item.class"
        v-for="(item, index) in info"
        :key="index"
        @click="linkTo(item)"
      >
        <i :class="item.icon"></i>
        <label>{{ item.label }}</label>
        <span>{{ item.value }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    homeRole: {
      type: Number,
      default: 2,
    },
    listData: {
      type: Array,
      default: null,
    },
  },
  data() {
    return {
      info: deptInfo,
    };
  },
  methods: {
    initData() {
      this.info.map((i) => {
        this.listData.map((j) => {
          if (i.label == j.type) {
            i.value = j.num;
          }
        });
        return i;
      });
    },
    linkTo(item) {
      this.$router.push(`/majorProjectPromotionProjectQuestion`);
    },
  },
  created() {
    if (this.homeRole == 1) {
      this.info = leaderInfo;
    }
  },
  watch: {
    listData(newVal) {
      if (newVal) {
        this.initData();
      }
    },
  },
};

const leaderInfo = [
  {
    label: "总数",
    value: 0,
    icon: "el-icon-s-management",
    color: "#909399",
    class: "status-total",
    linkUrl: "",
  },
  {
    label: "待交办",
    value: 0,
    icon: "el-icon-s-cooperation",
    color: "#E6A23C",
    class: "status-wait",
    linkUrl: "",
  },
  {
    label: "未反馈",
    value: 0,
    icon: "el-icon-s-release",
    color: "#F56C6C",
    class: "status-unfinish",
    linkUrl: "",
  },
  {
    label: "已反馈",
    value: 0,
    icon: "el-icon-s-claim",
    color: "#409EFF",
    class: "status-feedback",
    linkUrl: "",
  },
  {
    label: "已评价",
    value: 0,
    icon: "el-icon-s-check",
    color: "#67C23A",
    class: "status-evaluation",
    linkUrl: "",
  },
];
const deptInfo = [
  {
    label: "总数",
    value: 0,
    icon: "el-icon-s-management",
    color: "#909399",
    class: "status-total",
    linkUrl: "",
  },
  {
    label: "未反馈",
    value: 0,
    icon: "el-icon-s-release",
    color: "#F56C6C",
    class: "status-unfinish",
    linkUrl: "",
  },
  {
    label: "已反馈",
    value: 0,
    icon: "el-icon-s-claim",
    color: "#409EFF",
    class: "status-feedback",
    linkUrl: "",
  },
  {
    label: "已评价",
    value: 0,
    icon: "el-icon-s-check",
    color: "#67C23A",
    class: "status-evaluation",
    linkUrl: "",
  },
];
</script>

<style lang="scss" scoped>
@import "./home.scss";
</style>